import { handleLocalStorage } from "@/utils";
let openIdL = handleLocalStorage.get("openid");
import { defineStore } from "pinia";
import { ref } from "vue";

// export const useUserStore = defineStore("userStore", {
//   state: () => {
//     return {
//       openId: openIdL || "",
//     };
//   },
//   actions: {
//     clearStorage: () => {
//       // 清理openid
//       handleLocalStorage.remove("openid");
//       this.openId = "";
//     },
//   },
// });

export const useUserStore = defineStore("userStore", () => {
  const openId = ref("");
  openId.value = openIdL || "";
  const clearStorage = () => {
    handleLocalStorage.remove("openid");
    openId.value = "";
  };
  return {
    openId,
    clearStorage,
  };
});
